<?php
/**
 * Using POST
 **/
 
// see if any post request has been made
if(count($_POST) > 0){
    print_r($_POST);
}
 
/** Start Checkbox Example **/
if(isset($_POST['submit'])){
    if(isset($_POST['engine']) && is_array($_POST['engine'])){
        echo 'You selected: <br />';
        foreach($_POST['engine'] AS $engine){
            echo htmlentities($engine) . '<br />';
        }
    }else {
        echo 'Please select at least ONE search engine!<br />';
    }
}
?>
<form method="post">
    Choose Your Favorite Search Engine(s)<br />
    <input type="checkbox" name="engine[]" value="Google" /> Google<br />
    <input type="checkbox" name="engine[]" value="Yahoo" /> Yahoo<br />
    <input type="checkbox" name="engine[]" value="Bing" /> Bing<br />
    <input type="submit" name="submit" value="Submit" />
</form>
<!-- end checkbox example -->
<!-- last example -->
<?php
 
if(isset($_POST['submit'])){
    if(!empty($_POST['name'])){
        switch(strtolower($_POST['name'])){
            case 'marcus':
                echo 'Hello Professor!';
                break;
            
            case 'bob':
                echo 'Hello Mr. TA!';
                break;
                
            case 'amanda':
                echo 'Hello Student!';
                break;
            
            default:
                echo 'Invalid name supplied!';
        }
    }else {
        echo 'Please supply a name!';
    }
}
 
?>
<form method="post">
    Name: <input type="text" name="name" />
    <input type="submit" value="Submit" name="submit" />
</form>
<!-- end last example -->